<template>
  <div class="mb-7 sm:mx-auto sm:w-full sm:max-w-md">
    <h2 class="text-foreground mb-3 text-3xl font-bold leading-9 tracking-tight lg:text-4xl">欢迎登录</h2>
    <p class="lg:text-md text-sm">
      <span v-show="false" class="text-slate-500">请输入您的帐户信息以开始管理您的项目</span>
    </p>
  </div>
  <el-form class="mb-7" :model="formData" size="large" :rules="rules">
    <el-form-item prop="username">
      <el-input placeholder="用户名" v-model="formData.username" />
    </el-form-item>
    <el-form-item prop="password">
      <el-input show-password placeholder="密码" v-model="formData.password" />
    </el-form-item>
  </el-form>
  <el-button size="large" class="w-full mb-7" type="primary" @click="login">登录</el-button>
  <div></div>
  <el-button size="large" class="w-full mb-7" @click="switchScan">扫码登录</el-button>
</template>

<script setup lang="ts">
import { userStore } from '@/stores/user.ts'
import { reactive } from 'vue'
const user = userStore()
const emit = defineEmits(['switch'])
const login = () => {
  user.login(formData)
}
const formData = reactive({
  username: '',
  password: ''
})
const rules = reactive({
  username: [
    { required: true, message: '请输入用户名', trigger: 'blur' }
  ],
  password: [
    { required: true, message: '请输入密码', trigger: 'blur' }
  ]
})
const switchScan = () => {
  emit('switch', 'scan')
}
</script>

<style scoped>

</style>